package com.lagou.subjectone;

/**
 * 字符串统计
 */
public class SubjectOneMain {
    public static void main(String[] args) {
        String total = "ABCD123!@#%ab";
        System.out.println("统计字符串：" + total);
        //记录数值
        int bigABC = 0;
        int smallABC = 0;
        int num = 0;
        int other = 0;
        //循环目标字符串的每一个字符集
        for (int i = 0; i < total.length(); i++) {
            char x = total.charAt(i);
            if (Character.isUpperCase(x)) bigABC++;
            if (Character.isLowerCase(x)) smallABC++;
            if (Character.isDigit(x)) num++;
        }
        //减掉 大写字母 小写字母 数字，剩下就是其他字符
        other = total.length() - bigABC - smallABC - num;
        System.out.println("大写字符：" + bigABC);
        System.out.println("小写字符：" + smallABC);
        System.out.println("数字：" + num);
        System.out.println("其他字符：" + other);


    }
}
